<template>
  <div style="padding: 30px">
    <el-select
      @change="zhi()"
      v-model="value"
      placeholder="全部类型"
      style="padding-bottom: 30px; width: 100%"
    >
    <el-option label="全部" value=""></el-option>
      <el-option
        v-for="item in options"
        :key="item.id"
        :label="item.operationtype"
        :value="item.operationtype"
      >
      </el-option>
      
    </el-select>
    <el-table
      :data="
        tableData.slice((currentPage - 1) * pagesize, currentPage * pagesize)
      "
      border
      style="width: 100%"
    >
      <el-table-column prop="id" label="ID" width="180"> </el-table-column>
      <el-table-column prop="drugname" label="药品名称" width="180">
      </el-table-column>
      <el-table-column prop="batchnumber" label="药品批号" width="180">
      </el-table-column>
      <el-table-column prop="operationtime" label="操作时间"> </el-table-column>
      <el-table-column prop="operationtype" label="操作类型"> </el-table-column>
      <el-table-column prop="handler" label="经办人"> </el-table-column>
      <el-table-column prop="number" label="数量"> </el-table-column>
    </el-table>
    <el-pagination
      style="padding-top: 30px"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="tableData.length"
      :current-page.sync="page"
    >
    </el-pagination>
  </div>
</template>

 <script>
import { getList,getListDrug } from "../../../../api/drugrecordtable";
export default {
  data() {
    return {
      options: [], //下拉框绑定数据
      value: "",
      currentPage: 1,
      pagesize: 10,
      tableData: [], //表单绑定数据
    };
  },
  methods: {
    Lodwn() {
      getList().then((res) => {
        if (res.success) {
          this.tableData = res.result;
          this.options = res.result;         
        }
      });
    },
    handleSizeChange(val) {
      this.pagesize = val;
    },
    handleCurrentChange(val) {
      this.currentPage = val;
    },
    zhi() {
      console.log(this.value);
      if(this.value==null || this.value == ""){
          this.Lodwn();
          return
      }
      getListDrug({operationtype:this.value}).then((res) => {
        if (res.success) {
               this.tableData=res.result;   
        }
      });
      
      
    },
  },
  mounted() {
    this.Lodwn();
  },
};
</script>
